[% setvar title Rename the C<local> operator %]
<div id="archive-notice">
    <h3>This file is part of the Perl 6 Archive</h3>
    <p>To see what is currently happening visit <a href="http://www.perl6.org/">http://www.perl6.org/</a></p>
</div>
<div class='pod'>
<a name='TITLE'></a><h1>TITLE</h1>
<p>Rename the <code>local</code> operator</p>
<a name='VERSION'></a><h1>VERSION</h1>
<pre>  Maintainer: J. David Blackstone &lt;<a href='mailto:jdavidb@dfw.net'>jdavidb@dfw.net</a>&gt;
  Date: 4 Aug 2000
  Last Modified: 26 Sep 2000
  Mailing List: <a href='mailto:perl6-language@perl.org'>perl6-language@perl.org</a>
  Number: 19
  Version: 2
  Status: Frozen</pre>
<a name='ABSTRACT'></a><h1>ABSTRACT</h1>
<p>The <code>local</code> operator of Perl5 and earlier does not do what it claims
to and should be renamed.</p>
<a name='DESCRIPTION'></a><h1>DESCRIPTION</h1>
<p>New Perl programmers are often confused by the behavior of the
<code>local</code> operator, especially since a great deal of old educational
material exists showing the obsolete practice of using <code>local</code> to
create subroutine arguments and local variables.</p>
<p><code>local</code> does not provide variables that are local to the enclosing
scope.  Instead it permits what is known as dynamic assignment, the
ability to temporarily assign a value to a variable such that the
variable's original value will be restored when the current scope is
exited.  Relying on this mechanism to provide what most people think
of as local variables (lexical scoping) can sometimes fail.</p>
<p><code>local</code> is useful in many cases and should be retained but renamed to
reflect its action.</p>
<p>Although the majority of the Perl community is agreed that this
operator must be renamed, no consensus emerged as to what the new name
should be.  The author's favorites are <code>now</code> and <code>dynsave</code>, although
I find myself remembering a quote from a Tom Christiansen post about
the subject where he went on to discuss the possiblity of
&quot;scopetemp&quot;ing a lexical, so that seems catchy, too.</p>
<a name='IMPLEMENTATION'></a><h1>IMPLEMENTATION</h1>
<p>Many replacement names have been proposed for local on the
perl6-language list, and I am sure there are others that were proposed
on p5p in earlier days.</p>
<p>A list of other proposed replacement names includes (but is not
limited to, since I certainly have forgotten some):</p>
<p><code>now</code></p>
<p><code>dynsave</code></p>
<p><code>pushpop</code> (to reflect the fact that the variable's old value is
pushed onto a stack and popped off when the scope containing the use
of the operator is exited)</p>
<p><code>save</code></p>
<p><code>clone</code> (not a good idea, in my opinion.  I think that means making
an exact copy of an object.)</p>
<p><code>temp</code></p>
<p><code>savetemp</code></p>
<p><code>tempsave</code></p>
<p><code>scopetemp</code></p>
<p><code>current</code></p>
<p><code>scratchpad</code></p>
<p><code>deliver</code></p>
<p><code>preserve</code></p>
<p><code>saveval</code></p>
<p><code>tempval</code></p>
<p><code>saverestore</code></p>
<p><code>myval</code></p>
<p><code>pushval</code></p>
<p><code>contain</code></p>
<p><code>detach</code></p>
<p><code>revalue</code></p>
<p><code>let</code>  (I'm not sure this was a proposal)</p>
<p>None of these completely satisfies me, at the moment, and there does
not appear to be any consensus among the group.</p>
<a name='REFERENCES'></a><h1>REFERENCES</h1>
<p>The perlfunc manpage</p>
</div>
